﻿
namespace Imtihan.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;


    // Implements application logic using the ImtihanEntities context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public partial class ImtihanDomainService : LinqToEntitiesDomainService<ImtihanEntities>
    {

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Answers' query.
        public IQueryable<Answer> GetAnswers()
        {
            return this.ObjectContext.Answers;
        }

        public void InsertAnswer(Answer answer)
        {
            if ((answer.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(answer, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Answers.AddObject(answer);
            }
        }

        public void UpdateAnswer(Answer currentAnswer)
        {
            this.ObjectContext.Answers.AttachAsModified(currentAnswer, this.ChangeSet.GetOriginal(currentAnswer));
        }

        public void DeleteAnswer(Answer answer)
        {
            if ((answer.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Answers.Attach(answer);
            }
            this.ObjectContext.Answers.DeleteObject(answer);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Assessments' query.
        public IQueryable<Assessment> GetAssessments()
        {
            return this.ObjectContext.Assessments;
        }

        public void InsertAssessment(Assessment assessment)
        {
            if ((assessment.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(assessment, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Assessments.AddObject(assessment);
            }
        }

        public void UpdateAssessment(Assessment currentAssessment)
        {
            this.ObjectContext.Assessments.AttachAsModified(currentAssessment, this.ChangeSet.GetOriginal(currentAssessment));
        }

        public void DeleteAssessment(Assessment assessment)
        {
            if ((assessment.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Assessments.Attach(assessment);
            }
            this.ObjectContext.Assessments.DeleteObject(assessment);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'AssessmentCategories' query.
        public IQueryable<AssessmentCategory> GetAssessmentCategories()
        {
            return this.ObjectContext.AssessmentCategories;
        }

        public void InsertAssessmentCategory(AssessmentCategory assessmentCategory)
        {
            if ((assessmentCategory.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(assessmentCategory, EntityState.Added);
            }
            else
            {
                this.ObjectContext.AssessmentCategories.AddObject(assessmentCategory);
            }
        }

        public void UpdateAssessmentCategory(AssessmentCategory currentAssessmentCategory)
        {
            this.ObjectContext.AssessmentCategories.AttachAsModified(currentAssessmentCategory, this.ChangeSet.GetOriginal(currentAssessmentCategory));
        }

        public void DeleteAssessmentCategory(AssessmentCategory assessmentCategory)
        {
            if ((assessmentCategory.EntityState == EntityState.Detached))
            {
                this.ObjectContext.AssessmentCategories.Attach(assessmentCategory);
            }
            this.ObjectContext.AssessmentCategories.DeleteObject(assessmentCategory);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'AssessmentSchedules' query.
        public IQueryable<AssessmentSchedule> GetAssessmentSchedules()
        {
            return this.ObjectContext.AssessmentSchedules;
        }

        public void InsertAssessmentSchedule(AssessmentSchedule assessmentSchedule)
        {
            if ((assessmentSchedule.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(assessmentSchedule, EntityState.Added);
            }
            else
            {
                this.ObjectContext.AssessmentSchedules.AddObject(assessmentSchedule);
            }
        }

        public void UpdateAssessmentSchedule(AssessmentSchedule currentAssessmentSchedule)
        {
            this.ObjectContext.AssessmentSchedules.AttachAsModified(currentAssessmentSchedule, this.ChangeSet.GetOriginal(currentAssessmentSchedule));
        }

        public void DeleteAssessmentSchedule(AssessmentSchedule assessmentSchedule)
        {
            if ((assessmentSchedule.EntityState == EntityState.Detached))
            {
                this.ObjectContext.AssessmentSchedules.Attach(assessmentSchedule);
            }
            this.ObjectContext.AssessmentSchedules.DeleteObject(assessmentSchedule);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Categories' query.
        public IQueryable<Category> GetCategories()
        {
            return this.ObjectContext.Categories;
        }

        public void InsertCategory(Category category)
        {
            if ((category.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(category, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Categories.AddObject(category);
            }
        }

        public void UpdateCategory(Category currentCategory)
        {
            this.ObjectContext.Categories.AttachAsModified(currentCategory, this.ChangeSet.GetOriginal(currentCategory));
        }

        public void DeleteCategory(Category category)
        {
            if ((category.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Categories.Attach(category);
            }
            this.ObjectContext.Categories.DeleteObject(category);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Problems' query.
        public IQueryable<Problem> GetProblems()
        {
            return this.ObjectContext.Problems;
        }

        public void InsertProblem(Problem problem)
        {
            if ((problem.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(problem, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Problems.AddObject(problem);
            }
        }

        public void UpdateProblem(Problem currentProblem)
        {
            this.ObjectContext.Problems.AttachAsModified(currentProblem, this.ChangeSet.GetOriginal(currentProblem));
        }

        public void DeleteProblem(Problem problem)
        {
            if ((problem.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Problems.Attach(problem);
            }
            this.ObjectContext.Problems.DeleteObject(problem);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'ProblemAnswers' query.
        public IQueryable<ProblemAnswer> GetProblemAnswers()
        {
            return this.ObjectContext.ProblemAnswers;
        }

        public void InsertProblemAnswer(ProblemAnswer problemAnswer)
        {
            if ((problemAnswer.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(problemAnswer, EntityState.Added);
            }
            else
            {
                this.ObjectContext.ProblemAnswers.AddObject(problemAnswer);
            }
        }

        public void UpdateProblemAnswer(ProblemAnswer currentProblemAnswer)
        {
            this.ObjectContext.ProblemAnswers.AttachAsModified(currentProblemAnswer, this.ChangeSet.GetOriginal(currentProblemAnswer));
        }

        public void DeleteProblemAnswer(ProblemAnswer problemAnswer)
        {
            if ((problemAnswer.EntityState == EntityState.Detached))
            {
                this.ObjectContext.ProblemAnswers.Attach(problemAnswer);
            }
            this.ObjectContext.ProblemAnswers.DeleteObject(problemAnswer);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Questions' query.
        public IQueryable<Question> GetQuestions()
        {
            return this.ObjectContext.Questions;
        }

        public void InsertQuestion(Question question)
        {
            if ((question.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(question, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Questions.AddObject(question);
            }
        }

        public void UpdateQuestion(Question currentQuestion)
        {
            this.ObjectContext.Questions.AttachAsModified(currentQuestion, this.ChangeSet.GetOriginal(currentQuestion));
        }

        public void DeleteQuestion(Question question)
        {
            if ((question.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Questions.Attach(question);
            }
            this.ObjectContext.Questions.DeleteObject(question);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Roles' query.
        public IQueryable<Role> GetRoles()
        {
            return this.ObjectContext.Roles;
        }

        public void InsertRole(Role role)
        {
            if ((role.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(role, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Roles.AddObject(role);
            }
        }

        public void UpdateRole(Role currentRole)
        {
            this.ObjectContext.Roles.AttachAsModified(currentRole, this.ChangeSet.GetOriginal(currentRole));
        }

        public void DeleteRole(Role role)
        {
            if ((role.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Roles.Attach(role);
            }
            this.ObjectContext.Roles.DeleteObject(role);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Users' query.
        public IQueryable<User> GetUsers()
        {
            return this.ObjectContext.Users;
        }

        public void InsertUser(User user)
        {
            if ((user.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(user, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Users.AddObject(user);
            }
        }

        public void UpdateUser(User currentUser)
        {
            this.ObjectContext.Users.AttachAsModified(currentUser, this.ChangeSet.GetOriginal(currentUser));
        }

        public void DeleteUser(User user)
        {
            if ((user.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Users.Attach(user);
            }
            this.ObjectContext.Users.DeleteObject(user);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'UserAnswers' query.
        public IQueryable<UserAnswer> GetUserAnswers()
        {
            return this.ObjectContext.UserAnswers;
        }

        public void InsertUserAnswer(UserAnswer userAnswer)
        {
            if ((userAnswer.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(userAnswer, EntityState.Added);
            }
            else
            {
                this.ObjectContext.UserAnswers.AddObject(userAnswer);
            }
        }

        public void UpdateUserAnswer(UserAnswer currentUserAnswer)
        {
            this.ObjectContext.UserAnswers.AttachAsModified(currentUserAnswer, this.ChangeSet.GetOriginal(currentUserAnswer));
        }

        public void DeleteUserAnswer(UserAnswer userAnswer)
        {
            if ((userAnswer.EntityState == EntityState.Detached))
            {
                this.ObjectContext.UserAnswers.Attach(userAnswer);
            }
            this.ObjectContext.UserAnswers.DeleteObject(userAnswer);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'UserAssessmentSchedules' query.
        public IQueryable<UserAssessmentSchedule> GetUserAssessmentSchedules()
        {
            return this.ObjectContext.UserAssessmentSchedules;
        }

        public void InsertUserAssessmentSchedule(UserAssessmentSchedule userAssessmentSchedule)
        {
            if ((userAssessmentSchedule.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(userAssessmentSchedule, EntityState.Added);
            }
            else
            {
                this.ObjectContext.UserAssessmentSchedules.AddObject(userAssessmentSchedule);
            }
        }

        public void UpdateUserAssessmentSchedule(UserAssessmentSchedule currentUserAssessmentSchedule)
        {
            this.ObjectContext.UserAssessmentSchedules.AttachAsModified(currentUserAssessmentSchedule, this.ChangeSet.GetOriginal(currentUserAssessmentSchedule));
        }

        public void DeleteUserAssessmentSchedule(UserAssessmentSchedule userAssessmentSchedule)
        {
            if ((userAssessmentSchedule.EntityState == EntityState.Detached))
            {
                this.ObjectContext.UserAssessmentSchedules.Attach(userAssessmentSchedule);
            }
            this.ObjectContext.UserAssessmentSchedules.DeleteObject(userAssessmentSchedule);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'UserRoles' query.
        public IQueryable<UserRole> GetUserRoles()
        {
            return this.ObjectContext.UserRoles;
        }

        public void InsertUserRole(UserRole userRole)
        {
            if ((userRole.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(userRole, EntityState.Added);
            }
            else
            {
                this.ObjectContext.UserRoles.AddObject(userRole);
            }
        }

        public void UpdateUserRole(UserRole currentUserRole)
        {
            this.ObjectContext.UserRoles.AttachAsModified(currentUserRole, this.ChangeSet.GetOriginal(currentUserRole));
        }

        public void DeleteUserRole(UserRole userRole)
        {
            if ((userRole.EntityState == EntityState.Detached))
            {
                this.ObjectContext.UserRoles.Attach(userRole);
            }
            this.ObjectContext.UserRoles.DeleteObject(userRole);
        }
    }
}


